how to find the greatest and the smallest number of 6 digits